<template>
  <div class="">
    <div class="w-100 ib">Children</div>
    <el-select @change="getChildren" v-model="value" placeholder="Children data">
      <el-option
        v-for="item in childrenOptions"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
  </div>
</template>
 
<script>
import {mapActions, mapGetters, mapState} from 'vuex'
export default {
  name: '',
  data () {
    return {
      msg:''
    }
  },
  computed: {
    // 1.组件中v-model=“XXX”，而XXX是vuex state中的某个变量
    // 2.vuex中是单项流，v-model是vue中的双向绑定，但是在computed中只通过get获取参数值，没有set无法改变参数值
    ...mapState({
      // value: state => state.modCellData.value 
      //was assigned to but it has no setter.
    }),
    ...mapGetters({
      childrenOptions: 'moptions', 
      mvalue: 'mvalue' // getters not set,was assigned to but it has no setter.
    }),
    value: {
      get() {
        return this.mvalue
      },
      set(v) {
        return this.$store.state.modCellData.value = v
      }
    }
  },
  methods: {
    ...mapActions('modCellData', ['changeOption']),
    getChildren(v) {
      // this.changeOption(v)
      // this.$store.dispatch('modCellData/changeOption', v)
    }
  }
}
</script>
 
<style scoped lang="scss">
 
</style>